/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao;

import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import model.SysRoleMenuModel;
import util.DataUtil;

/**
 *
 * @author ThanhToan
 */
public class SysRoleDao {
    
    private static ArrayList<SysRoleMenuModel> getMenuByRole(String role){
        ArrayList<SysRoleMenuModel> sysMenuList = new ArrayList<SysRoleMenuModel>();
        try {
            CallableStatement csmt = DataUtil.getConnection().prepareCall("{call sp_GetMenuByRole(?)}");
            csmt.setString(role, "role");
            ResultSet rs = DataUtil.executeStore(csmt);
            while(rs.next()){
                SysRoleMenuModel sysMenuModel = new SysRoleMenuModel();
                sysMenuModel.setId(rs.getString("ID"));
                sysMenuModel.setRoleID(rs.getString("Role"));
                sysMenuModel.setMenuName(rs.getString("MenuName"));
                sysMenuModel.setUrl(rs.getString("URL"));
                sysMenuList.add(sysMenuModel);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return sysMenuList;
    }
    
}
